<?php

namespace App\Http\Requests\Api;

class ResetPasswordRequest extends FormRequest
{
    public function rules()
    {
        return [
            'user_mobile' => [
                'required',
                'exists:ucenter_user_info_detail',
                'regex:/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/'
            ],
            'sms_key' => 'required',
            'sms_code' => 'required',
            'password' => 'required|confirmed|min:6',
        ];
    }

    public function messages()
    {
        return [
            'user_mobile.required' => '手机号不能为空',
            'user_mobile.exists' => '手机号不存在',
            'user_mobile.regex' => '手机号不合法',
            'sms_key.required' => '验证码标识不能为空',
            'sms_code.required' => '验证码不能为空',
            'password.required' => '密码不能为空',
            'password.confirmed' => '两次密码不一致',
            'password.min' => '密码最少 6 位',
        ];
    }
}
